/**
 * 面试安排外部接口
 */
import request from '@/utils/request';

const getUserCode = () => localStorage.getItem('candidateUserCode') || '';

/**
 * 更新登记状态
 * @param {*} params
 */
export async function updateRegisterStatus(params) {
    // /api/oa/v1/work/recruitment/auth/candidates/external/application_forms/mobile/${params.resumeId}/actions/update_register_status
    return request(`/api/recruitment/v1/resumes/${params.resumeId}/actions/update_register_status`, {
        method: 'PUT',
        data: params,
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 更新求职意向
 * @param {*} params
 */
export async function updateSalary(params) {
    // /api/oa/v1/work/recruitment/auth/candidates/external/application_forms/mobile/${params.id}/actions/update_salary_will
    return request(`/api/recruitment/v1/resumes/${params.id}/actions/update_salary_will`, {
        method: 'PUT',
        data: params,
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 获取应聘登记表详情（新）
 */
export async function getRegisterDetail(interviewNoticeId) {
    console.log('getRegisterDetail-----');
    return request(`/api/recruitment/v1/candidates/external/application_forms/${interviewNoticeId}`, {
        method: 'GET',
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 获取工作经历
 */
export async function getWorkDetail(id) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${id}/actions/read_talent_work`, {
        method: 'GET',
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 更新工作经历
 * @param {*} params
 */
export async function updateWork(params) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${params?.id}/actions/update_talent_work`, {
        method: 'PUT',
        data: params,
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 新增工作经历
 * @param {*} params
 */
export async function addWork(params) {
    return request('/api/recruitment/public/v1/resumes/mobile/actions/save_talent_work', {
        method: 'POST',
        data: params,
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 删除工作经历
 */
export async function deleteWork(id) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${id}/actions/delete_talent_work`, {
        method: 'GET',
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 获取项目经历
 */
export async function getProjectDetail(id) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${id}/actions/read_talent_project`, {
        method: 'GET',
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 更新项目经历
 * @param {*} params
 */
export async function updateProject(params) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${params.id}/actions/update_talent_project`, {
        method: 'PUT',
        data: params,
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 新增项目经历
 * @param {*} params
 */
export async function addProject(params) {
    return request('/api/recruitment/public/v1/resumes/mobile/actions/save_talent_project', {
        method: 'POST',
        data: params,
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 删除项目经历
 */
export async function deleteProject(id) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${id}/actions/delete_talent_project`, {
        method: 'GET',
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 获取教育背景
 */
export async function getEducationDetail(id) {
    return request(`/api/recruitment/v1/resumes/${id}/actions/read_talent_edu`, {
        method: 'GET',
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 更新教育背景
 * @param {*} params
 */
export async function updateEducation(params) {
    //
    return request(`/api/recruitment/v1/resumes/${params.id}/actions/update_talent_edu`, {
        method: 'PUT',
        data: params,
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 新增教育背景
 * @param {*} params
 */
export async function addEducation(params) {
    // /api/oa/public/v1/work/recruitment/resumes/mobile/actions/save_talent_edu
    // /api/oa/v1/work/recruitment/auth/candidates/external/application_forms/mobile/actions/save_talent_edu
    return request('/api/recruitment/v1/resumes/actions/save_talent_edu', {
        method: 'POST',
        data: params,
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 删除教育背景
 */
export async function deleteEducation(id) {
    // /api/oa/public/v1/work/recruitment/resumes/mobile/${id}/actions/delete_talent_edu
    return request(`/api/recruitment/v1/resumes/${id}/actions/delete_talent_edu`, {
        method: 'GET',
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 获取培训经历
 */
export async function getTrainDetail(id) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${id}/actions/read_talent_train`, {
        method: 'GET',
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 更新培训经历
 * @param {*} params
 */
export async function updateTrain(params) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${params.id}/actions/update_talent_train`, {
        method: 'PUT',
        data: params,
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 新增培训经历
 * @param {*} params
 */
export async function addTrain(params) {
    return request('/api/recruitment/public/v1/resumes/mobile/actions/save_talent_train', {
        method: 'POST',
        data: params,
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 删除培训经历
 */
export async function deleteTrain(id) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${id}/actions/delete_talent_train`, {
        method: 'GET',
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 获取证书
 */
export async function getCertificateDetail(id) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${id}/actions/read_talent_certificate`, {
        method: 'GET',
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 更新证书
 * @param {*} params
 */
export async function updateCertificate(params) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${params.id}/actions/update_talent_certificate`, {
        method: 'PUT',
        data: params,
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 新增证书
 * @param {*} params
 */
export async function addCertificate(params) {
    return request('/api/recruitment/public/v1/resumes/mobile/actions/save_talent_certificate', {
        method: 'POST',
        data: params,
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 删除证书
 */
export async function deleteCertificate(id) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${id}/actions/delete_talent_certificate`, {
        method: 'GET',
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 获取专业技能
 */
export async function getSkillDetail(id) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${id}/actions/read_talent_skill`, {
        method: 'GET',
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 更新专业技能
 * @param {*} params
 */
export async function updateSkill(params) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${params.id}/actions/update_talent_skill`, {
        method: 'PUT',
        data: params,
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 新增专业技能
 * @param {*} params
 */
export async function addSkill(params) {
    return request('/api/recruitment/public/v1resumes/mobile/actions/save_talent_skill', {
        method: 'POST',
        data: params,
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 删除专业技能
 */
export async function deleteSkill(id) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${id}/actions/delete_talent_skill`, {
        method: 'GET',
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 获取语言能力
 */
export async function getLangDetail(id) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${id}/actions/read_talent_lang`, {
        method: 'GET',
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 更新语言能力
 * @param {*} params
 */
export async function updateLang(params) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${params.id}/actions/update_talent_lang`, {
        method: 'PUT',
        data: params,
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 新增语言能力
 * @param {*} params
 */
export async function addLang(params) {
    return request('/api/recruitment/public/v1/resumes/mobile/actions/save_talent_lang', {
        method: 'POST',
        data: params,
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}

/**
 * 删除语言能力
 */
export async function deleteLang(id) {
    return request(`/api/recruitment/public/v1/resumes/mobile/${id}/actions/delete_talent_lang`, {
        method: 'GET',
        headers: {
            current_account_user_code: getUserCode()
        }
    });
}
